package lev01_beginnerClass.util;

public class HelpUtil {

    public static int[] generateRandomArr(int maxlen,int maxvalue){
        int len = (int)(Math.random()*maxlen);
        int[] arr = new int[len];
        for(int i = 0;i < len;i++){
            arr[i] = (int)(Math.random()*maxvalue);
        }
        return arr;
    }

    /**
     * generate array with two rejacent numbet is not equal
     * @param maxLen
     * @param minValue
     * @param maxValue
     * @return
     */
    public static int[] generateRandomArrRejacentNotEqual(int maxLen,int minValue,int maxValue){
        int len = (int)((Math.random()*(maxLen+1)));
        int[] arr = new int[len];

        if(len >= 1){
            arr[0] = (int)(Math.random()*(maxValue - minValue+1))+minValue;
            for(int i = 1;i < arr.length;i++){
                do {
                    arr[i] = (int)(Math.random()*(maxValue - minValue+1))+minValue;
                }while (arr[i] == arr[i-1]);
            }
            return  arr;
        }
        return arr;
    }


}
